package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.GoodsDTO;
import com.cskaoyan.wordmemorize.dto.admin.PageDTO;
import com.cskaoyan.wordmemorize.request.GoodsPageRequest;
import com.cskaoyan.wordmemorize.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 顾海龙
 * @version 1.0
 */
@RestController
@ResponseBody
public class AppGoodsController {

    @Autowired
    GoodsService goodsService;

    @GetMapping("/product")
    public Result AppGetGoodsList(@ModelAttribute GoodsPageRequest goodsPageRequest){
        PageDTO<GoodsDTO> pageDTO;
        try {
            pageDTO = goodsService.appGetGoodsPage(goodsPageRequest);
        } catch (Exception e) {
            return Result.fail();
        }
        return Result.ok(pageDTO);
    }
}
